#include <stdio.h>
#include <stdlib.h>	/* exit() */
#include <string.h>
#include <pthread.h>
#include <sys/time.h>
#include <time.h>
#include <limits.h>
#include <errno.h>
#include <signal.h>
#include <dirent.h>


/*
 * 列出一个目录中的所有文件
 */


int main(int argc, char ** argv)
{
	DIR * dp;
	struct dirent *dirp;

	if (argc != 2)
		perror("usage : ls directory name");

	if (( dp = opendir(argv[1])) == NULL)
		printf("can't open %s", argv[1]);
	while ((dirp = readdir(dp)) != NULL)
		printf("%s\n", dirp->d_name);

	closedir(dp);
	exit(0);
}